/**
 * 描述：
 * Copyright：Copyright （c） 2019
 * Company：南京银行
 * @author jxgu 
 * @version 1.0 2019年8月26日
 * @see history
 * 2019年8月26日
 */
package com.njcb.ams.interaction;

import java.util.HashMap;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import com.njcb.ams.pojo.dto.ProjectInfoQueryRequest;
import com.njcb.ams.pojo.dto.ProjectInfoQueryResponse;
import com.njcb.ams.service.DataDicService;
import com.njcb.ams.service.ProjectInfoService;
import com.njcb.ams.support.annotation.Interaction;
import com.njcb.ams.support.annotation.Trader;

/**
 * @author jxgu
 *
 *         类功能描述：
 *
 */
@Service
@Lazy(false)
@Interaction
public class ProjectInfoManager {

	private static final Logger logger = LoggerFactory.getLogger(ProjectInfoManager.class);

	@Autowired
	private ProjectInfoService projectInfoService;

	@Autowired
	private BusinessWrokflowManager wrokflowManager;

	/**
	 * 
	 * 方法功能描述：查询交易
	 * 
	 * @param request
	 * @return
	 */
	@Trader(tradeCode = "PM001", tradeName = "查询需求列表交易")
	public List<ProjectInfoQueryResponse> query(ProjectInfoQueryRequest request) {
		logger.info("查询需求交易");
		return projectInfoService.projectInfoQuery(request);
	}

	@Trader(tradeCode = "PM002", tradeName = "保存需求信息")
	public int saveProjectInfo(ProjectInfoQueryRequest projectInfoReq) {
		int ret = projectInfoService.saveProjectInfo(projectInfoReq);
		DataDicService.getInstance().reloadDataDicByType("PM");
		return ret;
	}

	@Trader(tradeCode = "PM003", tradeName = "删除需求信息")
	public int deleteProjectInfo(ProjectInfoQueryRequest projectInfo) {
		int ret = projectInfoService.deleteProjectInfo(projectInfo);
		DataDicService.getInstance().reloadDataDicByType("PM");
		return ret;
	}

	@Trader(tradeCode = "PM004", tradeName = "提交需求信息")
	public int commitProjectInfo(ProjectInfoQueryRequest projectInfo) {
		int ret = projectInfoService.commitProjectInfo(projectInfo);
		DataDicService.getInstance().reloadDataDicByType("PM");
		HashMap<String, Object> param = new HashMap<String, Object>();
		param.put("isproject", projectInfo.getIsProject());// 项目
		String processkey = "需求流转流程";
		wrokflowManager.workFlowStart(processkey, String.valueOf(ret), param);
		return ret;
	}
}
